package com.face.server.controller;

import com.face.RespMsg;
import com.face.server.service.AdminVisitorService;
import com.face.server.service.impl.VisitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;


/**
 * Created by ryan on 2018/3/19.
 */
@RestController
@RequestMapping("/adminVisitor")
public class AdminVisitorCtroller {

    @Autowired
    private AdminVisitorService adminVisitorService;

    @Autowired
    private VisitorService visitorService;

    @GetMapping("/listVisitors")
    public RespMsg listVisitors(@RequestParam(required = false) String key, @PageableDefault(sort ={"dormitoryNum","dormitoryBuildNum"},size = 10000) Pageable pageable){
        return RespMsg.build(adminVisitorService.listVisitors(pageable,key));
    }

    @GetMapping("/findOne/{id}")
    public RespMsg findOne(@PathVariable String id){
        return visitorService.findById(id);
    }
}
